
// import { random } from 'core-js/core/number';
import { List } from 'echarts';
import Mock from 'mockjs'
import { param2Obj } from "../utils/urlUtils";
var cropTypeList = ["草莓","辣椒","西瓜","葡萄","黄瓜","西红柿","香瓜","哈密瓜"]
var equipmentList = ["浇灌系统","控温系统","加湿系统","光照系统"]
var logList = [];
for (var i=0; i<100;i++){
    var n = Math.floor(Math.random() * cropTypeList.length + 1)-1
    var e = Math.floor(Math.random() * equipmentList.length + 1)-1
    var stateVal = Mock.mock('@boolean');
    logList.push({
        id:Mock.mock('@guid()'),
            date: Mock.mock('@date("2022-06-dd")'),
            croptype: cropTypeList[n],
            growstate: Mock.mock('@natural(0, 2)'),
            equipment: equipmentList[e],
            value: stateVal,
            work: stateVal
    })
    
}
export default{
    getLogData:config => {
        // console.log(config);
    var { shearchWord,page,pageSize }  =  param2Obj(config.url)
    var res = logList.filter(item => item.croptype.indexOf(shearchWord) != -1)
    var resLimit = res.filter((item,index) => {
        return ( page-1) * pageSize <= index && index < page * pageSize
    })
        return {
            code:200,
            msg: '请求成功',
            data:resLimit,
            total:logList.length
        }
    }
}
